﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ProductServiceReference;

/// <summary>
/// Summary description for ShoppingCart
/// </summary>
public class ShoppingCart
{
    private IList<Product> Items = new List<Product>();

    public void Add(Product prod)
    {
        if (HttpContext.Current.Session["ShoppingCart"] == null)
        {
            HttpContext.Current.Session["ShoppingCart"] = Items;
        }
        else
        {
            foreach (var product in Items.Where(product => product.ProductID.Equals(prod.ProductID)))
            {
                product.Quantity += 1;
                return;
            }
        }
    }

    public void Delete(Product prod)
    {
        Items.Remove(prod);
    }
}

